# https://www.kimi.com/chat/d21cto5s8fb5gej8tukg
from sklearn.datasets import make_moons
from sklearn.svm import SVC
import matplotlib.pyplot as plt
import numpy as np

# 1) 造一个非线性数据集（两个交错的半月）
X, y = make_moons(n_samples=300, noise=0.25, random_state=42)

# 2) 训练 RBF-SVM
model = SVC(kernel='poly', C=1.0, gamma=0.7)   # 关键就这一行
model.fit(X, y)

# 3) 画决策边界
xx, yy = np.meshgrid(np.linspace(-1.5, 2.5, 500),
                     np.linspace(-1, 1.5, 500))
Z = model.decision_function(np.c_[xx.ravel(), yy.ravel()]).reshape(xx.shape)

plt.figure(figsize=(6,5))
plt.contourf(xx, yy, Z, levels=25, cmap='coolwarm', alpha=0.8)
plt.scatter(X[:,0], X[:,1], c=y, cmap='coolwarm', edgecolors='k')
plt.title("SVC with RBF kernel")
plt.show()